package thread.J20240321;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: nn
 * Date: 2025-05-05
 * Time: 上午9:56
 */

class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println("hello thread");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
public class Demo1 {
    public static void main(String[] args) {
        Thread t = new MyThread();
        t.start();

        //没有创建新的线程，就是在主线程中执行上述 run 中的循环打印
        t.run();
        while (true){
            System.out.println("hello mian");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
